/*
+--------------------------
| FreeloaderOS v0.0.1
|  - Microkernel
+--------------------------
| Written by Alec Hussey
| Copyright (c) 2007
|  - Deus X Foundation
+---------------------------
*/

/*
 * Keyboard Contoller
 */

#ifndef _KEYBOARD_H
#define _KEYBOARD_H

#define META_ALT    0x0200  // Alt is pressed
#define META_CTRL   0x0400  // Control is pressed
#define META_SHIFT  0x0800  // Shift is pressed
#define META_ANY    (META_ALT | META_CTRL | META_SHIFT)
#define META_CAPS   0x1000  // Caps Lock is on
#define META_NUM    0x2000  // Num lock is on
#define META_SCRL   0x4000  // Scroll Lock is on

#define KEY_ESC          1
#define KEY_F1           0x80
#define KEY_F2           (KEY_F1 + 1)
#define KEY_F3           (KEY_F2 + 1)
#define KEY_F4           (KEY_F3 + 1)
#define KEY_F5           (KEY_F4 + 1)
#define KEY_F6           (KEY_F5 + 1)
#define KEY_F7           (KEY_F6 + 1)
#define KEY_F8           (KEY_F7 + 1)
#define KEY_F9           (KEY_F8 + 1)
#define KEY_F10          (KEY_F9 + 1)
#define KEY_F11          (KEY_F10 + 1)
#define KEY_F12          (KEY_F11 + 1)

#define KEY_INS          0x90
#define KEY_DEL          (KEY_INS + 1)
#define KEY_HOME         (KEY_DEL + 1)
#define KEY_END          (KEY_HOME + 1)
#define KEY_PGUP         (KEY_END + 1)
#define KEY_PGDN         (KEY_PGUP + 1)
#define KEY_LEFT         (KEY_PGDN + 1)
#define KEY_UP           (KEY_LEFT + 1)
#define KEY_DN           (KEY_UP + 1)
#define KEY_RIGHT        (KEY_DN + 1)

#define KEY_LEFT_ALT     0x38
#define KEY_RIGHT_ALT    0x38
#define KEY_LEFT_CTRL    0x1D
#define KEY_RIGHT_CTRL   0x1D
#define KEY_LEFT_SHIFT   0x2A
#define KEY_RIGHT_SHIFT  0x36
#define KEY_CAPSLOCK     0x3A
#define KEY_NUMLOCK      0x45
#define KEY_SCRLLOCK     0x46

int shift = 0;

/*
Standard US Keyboard Layout
*/
#ifndef _LIBC_STDIO_H

static unsigned char kbdus[] =
{
	0, 27, 
	'1', '2', 
	'3', '4', 
	'5', '6', 
	'7', '8', 
	'9', '0', 
	'-', '=', 
	'\b', '\t', 
	'q', 'w', 
	'e', 'r', 
	't', 'y', 
	'u', 'i', 
	'o', 'p', 
	'[', ']', 
	'\n', 0, 
	'a', 's', 
	'd', 'f', 
	'g', 'h', 
	'j', 'k', 
	'l', ';', 
	'\'', '`', 
	0, '\\', 
	'z', 'x', 
	'c', 'v', 
	'b', 'n', 
	'm', ',', 
	'.', '/', 
	0, 0, 
	0, ' ', 
	0, KEY_F1, 
	KEY_F2, KEY_F3, 
	KEY_F4, KEY_F5, 
	KEY_F6, KEY_F7, 
	KEY_F8, KEY_F9, 
	KEY_F10, 0, 
	0, KEY_HOME, 
	KEY_UP, KEY_PGUP, 
	'-', KEY_LEFT, 
	'5', KEY_RIGHT, 
	'+', KEY_END, 
	KEY_DN, KEY_PGDN, 
	KEY_INS, KEY_DEL, 
	0, 0, 
	0, KEY_F11, 
	KEY_F12
};

static unsigned char kbdus_caps[] =
{
	0, 27, 
	'!', '@', 
	'#', '$', 
	'%', '^', 
	'&', '*', 
	'(', ')', 
	'_', '+', 
	'\b', '\t', 
	'Q', 'W', 
	'E', 'R', 
	'T', 'Y', 
	'U', 'I', 
	'O', 'P', 
	'{', '}', 
	'\n', 0, 
	'A', 'S', 
	'D', 'F', 
	'G', 'H', 
	'J', 'K', 
	'L', ':', 
	'"', '~', 
	0, '|', 
	'Z', 'X', 
	'C', 'V', 
	'B', 'N', 
	'M', '<', 
	'>', '?', 
	0, 0, 
	0, ' ', 
	0, KEY_F1, 
	KEY_F2, KEY_F3, 
	KEY_F4, KEY_F5, 
	KEY_F6, KEY_F7, 
	KEY_F8, KEY_F9, 
	KEY_F10, 0, 
	0, KEY_HOME, 
	KEY_UP, KEY_PGUP, 
	'-', KEY_LEFT, 
	'5', KEY_RIGHT, 
	'+', KEY_END, 
	KEY_DN, KEY_PGDN, 
	KEY_INS, KEY_DEL, 
	0, 0, 
	0, KEY_F11, 
	KEY_F12
};

#endif
#endif
